package com.xzc.jcip._2_.线程安全性问题;

import net.jcip.annotations.ThreadSafe;

import java.util.concurrent.atomic.AtomicLong;

/**
 * 使用线程安全类来将竞态条件-原子化
 */
@ThreadSafe
public class CountingFactorizer {
    private final AtomicLong count = new AtomicLong(0);

    public long getCount() {
        return count.get();
    }

    public void service() {
        count.incrementAndGet();
    }
}
